﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using YJKRevitCode.ElmentSearchUtility.LinkDocumentSuite;
using SectionSignAndFilled.StairsRoomSection.DataDefine;
using SectionSignAndFilled.StairsRoomSection.Kit;
using SectionSignAndFilled.StairsRoomSection.Kit.CutLine;

namespace SectionSignAndFilled.StairsRoomSection.ElementPacket
{
	public class ComLayerObject : ElementObject
	{
		public ComLayerObject(BaseLinkDocumentResultBean LinkElem, SectionViewData secviewData = null) : base(LinkElem, secviewData)
		{
			this.m_objectType = ObjectType.kLayerType;
		}

		public int MaxLayerIndex
		{
			get
			{
				return this.m_nMaxLayerIndex;
			}
		}

		public int MinLayerIndex
		{
			get
			{
				return this.m_nMinLayerIndex;
			}
		}

		public override List<ElementObject> DividChild()
		{
			HostObject hostObject = base.SelfElem.UseElement as HostObject;
			if (hostObject == null)
			{
				return base.LstChildObj;
			}
			Element element = hostObject.Document.GetElement(hostObject.GetTypeId());
			HostObjAttributes hostObjAttributes = element as HostObjAttributes;
			CompoundStructure compoundStructure = hostObjAttributes.GetCompoundStructure();
			if (compoundStructure == null)
			{
				return base.LstChildObj;
			}
			IList<CompoundStructureLayer> layers = compoundStructure.GetLayers();
			foreach (CompoundStructureLayer compoundStructureLayer in layers)
			{
				LayerObject layerObject = new LayerObject(base.SelfElem, base.SecViewData);
				layerObject.m_IndexPos = compoundStructureLayer.LayerId;
				layerObject.m_dWidth = compoundStructureLayer.Width;
				Material material = hostObject.Document.GetElement(compoundStructureLayer.MaterialId) as Material;
				if (material != null)
				{
					layerObject.m_strMaterial = material.Name;
				}
				LayerCutLineGetter cutLineBehavior = new LayerCutLineGetter();
				layerObject.SetCutLineBehavior(cutLineBehavior);
				base.LstChildObj.Add(layerObject);
			}
			if (base.LstChildObj.Count > 0)
			{
				this.m_nMaxLayerIndex = (base.LstChildObj[base.LstChildObj.Count - 1] as LayerObject).m_IndexPos;
				this.m_nMinLayerIndex = (base.LstChildObj[0] as LayerObject).m_IndexPos;
			}
			return base.LstChildObj;
		}

		public virtual Plane GetLastLayerCutPlane(int index, Line cutLine)
		{
			return null;
		}

		private int m_nMaxLayerIndex;

		private int m_nMinLayerIndex;
	}
}
